<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 20px;
            height: 20px;
            background: skyblue;
            border-radius: 50%;
            position: absolute;
        }
    </style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>


<script type="text/javascript">
    function getPos(ev) {
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;

        return{x:ev.clientX+scrollLeft,y:ev.clientY+scrollTop};

    }
    document.onmousemove = function (ev) {
        var aDiv = document.getElementsByTagName('div');

        var oEvent = ev|| event;

        for(var i=aDiv.length-1;i>0;i--){
            aDiv[i].style.left = aDiv[i-1].offsetLeft+'px';
            aDiv[i].style.top = aDiv[i-1].offsetTop+'px';
        }

        aDiv[0].style.left = getPos(oEvent).x+'px';
        aDiv[0].style.top = getPos(oEvent).y+'px';

    }



</script>

</body>
</html>